<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .a {
            width: 100px;
            height: 100px;
            background-color: #000;
            border: 10px solid #f00;
            padding: 20px;
        }
    </style>
</head>

<body>

    <div class="a"></div>

    <script>

        // getComputedStyle(oA).width   盒子的宽度

        // clientWidth   盒子加内边距

        // offsetWidth   盒子加内边距加边框



        var oA = document.querySelector('.a');

        // console.log(getComputedStyle(oA).width);   // 字符串

        // 盒子加内边距
        console.log(oA.clientWidth);

        // 盒子加内边距加边框
        console.log(oA.offsetWidth);

    </script>

</body>

</html>